<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>加加减减</title>
</head>

<body>
	<div id="app">
		<ul>
			<li v-for="(item, index) in list" :key="index">
				{{ item }}
				<button @click="list.splice(index, 1)">删除</button>
			</li>
		</ul>
		<button @click="randomList()">生成</button>
	</div>
	<script src="../vue.js"></script>
	<script>
		let app = new Vue({
			el: '#app',
			data: {
				list: [1, 2, 3, 4, 5]
			},
			methods: {
				randomList() {
					this.list.push(Math.floor(Math.random() * 21))
				}
			}
		})
	</script>
</body>

</html>